<?php
declare(strict_types = 1);

namespace app\shop\controller;

use app\Normal;
use think\annotation\Route;
use think\annotation\route\Group;
use \app\common\service\GoodsService\GoodsService as Goods_Service;
use think\annotation\route\Middleware;

/**
 * 商品服务
 * @Group("GoodsService")
 * @Middleware({shopMiddileware::class})
 */
class GoodsService extends \app\BaseShopController
{
    /**
     * 服务列表
     * @Route("serviceLists",method="GET")
     * @return void
     */
    public function serviceLists(){
        $result = callApi(Goods_Service::class, 'serviceLists',$this->_all_data);
        return apiResponse($result);
    }
    
     /**
     * 服务列表不分页
     * @Route("serviceListsNoPage",method="GET")
     * @return void
     */
    public function serviceListsNoPage(){
        $result = callApi(Goods_Service::class, 'serviceListsNoPage',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 新增商品服务
     * @Route("addService",method="POST")
     * @return void
     */
    public function addService(){
        $result = callApi(Goods_Service::class, 'addService',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'新增商品服务','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }

    /**
     * 服务详情
     * @Route("serviceInfo/:id",method="GET")
     * @return void
     */
    public function serviceInfo(){
        $result = callApi(Goods_Service::class, 'serviceInfo',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 修改商品服务
     * @Route("editGoodsService",method="PUT")
     * @return void
     */
    public function editGoodsService(){
        $result = callApi(Goods_Service::class, 'editGoodsService',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'修改商品服务ID为【'.$this->_all_data['id'].'】的内容','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }

    /**
     * 切换商品服务状态
     * @Route("changeStatusService",method="GET")
     * @return void
     */
    public function changeStatusService(){
        $result = callApi(Goods_Service::class, 'changeStatusService',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'切换商品服务ID为'.$this->_all_data['id'].'的状态为【'.$this->_all_data['status'].'】','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }

    /**
     * 切换商品服务默认
     * @Route("changeStatusService",method="GET")
     * @return void
     */
    public function changeDefaultService(){
        $result = callApi(Goods_Service::class, 'changeDefaultService',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'切换商品服务ID为'.$this->_all_data['id'].'的默认状态为【'.$this->_all_data['is_default'].'】','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }
}